var __extends =
    (this && this.__extends) ||
    (function () {
      var e = function (t, n) {
        return (e =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (e, t) {
              e.__proto__ = t;
            }) ||
          function (e, t) {
            for (var n in t)
              Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
          })(t, n);
      };
      return function (t, n) {
        function i() {
          this.constructor = t;
        }
        if ("function" != typeof n && null !== n)
          throw new TypeError(
            "Class extends value " + String(n) + " is not a constructor or null"
          );
        e(t, n),
          (t.prototype =
            null === n
              ? Object.create(n)
              : ((i.prototype = n.prototype), new i()));
      };
    })(),
  CommunicateDialog = (function (e) {
    function t() {
      var t = e.call(this) || this;
      return (
        (t.isOpen = !1),
        (t.onLoadNPCDialogMessageFn = {
          caller: t,
          code: 205,
          method: function (e) {
            if (0 == e.code) {
              var n = e.data;
              if (n) {
                var i = n.c;
                i &&
                  (i = (i = i.replace("[name]", Global.roleName)).replace(
                    "[name]",
                    Global.roleName
                  )),
                  (t.list_btn.selectedIndex = -1),
                  (t.list_btn.array = []),
                  (t.label_otherName.text = n.n),
                  (t.label_communicateContent.text = i),
                  (t.communicationObj = n),
                  0 == n.t
                    ? ((t.list_btn.visible = !1),
                      (t.label_nextStep.visible = !0),
                      (t.label_nextStep.text = "返回"),
                      Laya.stage.event("GameMainView", "update_task"),
                      Global.isOldeVersion &&
                        Laya.stage.event("HomePageView", "update_task"))
                    : 1 == n.t
                    ? ((t.list_btn.visible = !1),
                      (t.label_nextStep.visible = !0),
                      (t.label_nextStep.text = "继续 >>"))
                    : 2 == n.t &&
                      (n.list.length > 0
                        ? ((t.label_nextStep.visible = !1),
                          (t.list_btn.visible = !0),
                          t.setListBtn(n.list))
                        : ((t.label_nextStep.visible = !0),
                          (t.list_btn.visible = !1)),
                      Laya.stage.event("GameMainView", "update_task"),
                      Global.isOldeVersion &&
                        Laya.stage.event("HomePageView", "update_task")),
                  t.isOpen || ((t.isOpen = !0), t.popup(!0)),
                  n.p &&
                    n.p.length > 0 &&
                    (ReceiveAwardDialog.showReceiveAwardDialog(n),
                    Laya.stage.event("GameMainView", "exp"),
                    Laya.stage.event("GameMainView", "moeny"),
                    Laya.stage.event("GameMainView", "update_task"),
                    Global.isOldeVersion &&
                      (Laya.stage.event("HomePageView", "exp"),
                      Laya.stage.event("HomePageView", "moeny"),
                      Laya.stage.event("HomePageView", "update_task")));
              } else
                t.isOpen &&
                  ((t.isOpen = !1),
                  t.close(),
                  Laya.stage.event("GameMainView", "npc"),
                  Laya.stage.event("HomePageView", "npc"));
            } else ToastView.toastView(e.msg);
          },
        }),
        (t.onLoadYinYangShiZheNPCFn = {
          caller: t,
          code: 0,
          method: function (e) {
            t.label_communicateContent.text = e.content;
          },
        }),
        (t.closeHandler = new Handler(t, t.onCloseFn)),
        t.label_nextStep.on(Laya.Event.CLICK, t, t.onNextStepFn),
        t.label_communicateContent.on(Laya.Event.CLICK, t, t.onNextStepFn),
        (t.list_btn.selectEnable = !0),
        (t.list_btn.selectHandler = new Handler(t, t.listBtnOnClick)),
        WebSocketService.addListener(t.onLoadNPCDialogMessageFn, !0),
        t
      );
    }
    return (
      __extends(t, e),
      (t.showCommunicationDialog = function (e) {
        null == this.communicateV &&
          ((this.communicateV = new t()), (this.communicateV.zOrder = 1e3)),
          (this.communicateV.isOpen = !1),
          this.communicateV.initCommonView(),
          (this.communicateV.dictObj = e),
          WebSocketService.send({ c: 205, d: { id: e.id, r: -1 } });
      }),
      (t.prototype.initCommonView = function () {
        (this.label_otherName.text = ""),
          (this.label_myselfName.text = ""),
          (this.label_communicateContent.text = ""),
          (this.list_btn.selectedIndex = -1);
      }),
      (t.showNextCommunicationDialog = function (e) {
        null == this.communicateV &&
          ((this.communicateV = new t()), (this.communicateV.zOrder = 1e3)),
          this.communicateV.popup(!0);
      }),
      (t.prototype.setListBtn = function (e) {
        for (var t, n = [], i = 0; i < e.length; i++) {
          (t = { btn_item: { label: e[i].c } }), n.push(t);
        }
        this.list_btn.array = n;
      }),
      (t.prototype.listBtnOnClick = function (e) {
        e < 0 ||
          WebSocketService.send({ c: 205, d: { id: this.dictObj.id, r: e } });
      }),
      (t.prototype.onNextStepFn = function () {
        0 == this.communicationObj.t &&
          (Laya.stage.event("GameMainView", "npc"),
          Laya.stage.event("HomePageView", "npc"),
          this.communicationObj.i &&
            this.communicationObj.i > 0 &&
            WebSocketService.send({
              c: 1153,
              d: { mid: this.communicationObj.i },
            }),
          this.close()),
          1 == this.communicationObj.t &&
            WebSocketService.send({
              c: 205,
              d: { id: this.dictObj.id, r: -1 },
            });
      }),
      (t.prototype.onCloseFn = function (e) {}),
      (t.staticClose = function () {
        null != this.communicateV && this.communicateV.close();
      }),
      t
    );
  })(ui.common.CommunicateDialogUI);
